package com.ruoyi.project.yuwen.audioapprovelog.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.yuwen.audioapprovelog.domain.AudioApproveLog;
import com.ruoyi.project.yuwen.audioapprovelog.service.IAudioApproveLogService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 音频审核日志Controller
 * 
 * @author shixiangwen
 * @date 2021-03-24
 */
@Controller
@RequestMapping("/yuwen/audioapprovelog")
public class AudioApproveLogController extends BaseController
{
    private String prefix = "yuwen/audioapprovelog";

    @Autowired
    private IAudioApproveLogService audioApproveLogService;

    @RequiresPermissions("yuwen:audioapprovelog:view")
    @GetMapping()
    public String audioapprovelog()
    {
        return prefix + "/audioapprovelog";
    }

    /**
     * 查询音频审核日志列表
     */
    @RequiresPermissions("yuwen:audioapprovelog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AudioApproveLog audioApproveLog)
    {
        startPage();
        List<AudioApproveLog> list = audioApproveLogService.selectAudioApproveLogList(audioApproveLog);
        return getDataTable(list);
    }

    /**
     * 导出音频审核日志列表
     */
    @RequiresPermissions("yuwen:audioapprovelog:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AudioApproveLog audioApproveLog)
    {
        List<AudioApproveLog> list = audioApproveLogService.selectAudioApproveLogList(audioApproveLog);
        ExcelUtil<AudioApproveLog> util = new ExcelUtil<AudioApproveLog>(AudioApproveLog.class);
        return util.exportExcel(list, "audioapprovelog");
    }

    /**
     * 新增音频审核日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存音频审核日志
     */
    @RequiresPermissions("yuwen:audioapprovelog:add")
    @Log(title = "音频审核日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AudioApproveLog audioApproveLog)
    {
        return toAjax(audioApproveLogService.insertAudioApproveLog(audioApproveLog));
    }

    /**
     * 修改音频审核日志
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        AudioApproveLog audioApproveLog = audioApproveLogService.selectAudioApproveLogById(id);
        mmap.put("audioApproveLog", audioApproveLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存音频审核日志
     */
    @RequiresPermissions("yuwen:audioapprovelog:edit")
    @Log(title = "音频审核日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AudioApproveLog audioApproveLog)
    {
        return toAjax(audioApproveLogService.updateAudioApproveLog(audioApproveLog));
    }

    /**
     * 删除音频审核日志
     */
    @RequiresPermissions("yuwen:audioapprovelog:remove")
    @Log(title = "音频审核日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(audioApproveLogService.deleteAudioApproveLogByIds(ids));
    }
}
